import torch
def f(x):
    return torch.pow((x-2.0),2)

x = torch.tensor([-3.5],requires_grad=True)

value = f(x)
print(value)
value.backward()
print(x.grad)
print(value.grad_fn)